<!DOCTYPE HTML>
<html>
<head>
	<meta charset="utf-8">
	<meta name="renderer" content="webkit|ie-comp|ie-stand">
	<meta http-equiv="X-UA-Compatible" content="IE=edge,chrome=1">
	<meta name="viewport"
	content="width=device-width,initial-scale=1,minimum-scale=1.0,maximum-scale=1.0,member-scalable=no" />
	<meta http-equiv="Cache-Control" content="no-siteapp" />
<!--[if lt IE 9]>
<script type="text/javascript" src="lib/html5.js"></script>
<script type="text/javascript" src="lib/respond.min.js"></script>
<script type="text/javascript" src="lib/PIE_IE678.js"></script>
<![endif]-->
<link href="<%=basePath%>backstage/css/H-ui.css" rel="stylesheet"
type="text/css" />
<link href="<%=basePath%>backstage/css/H-ui.admin.css" rel="stylesheet"
type="text/css" />
<link href="<%=basePath%>backstage/lib/Hui-iconfont/1.0.6/iconfont.css"
rel="stylesheet" type="text/css" />
<link href="<%=basePath%>backstage/css/style.css" rel="stylesheet"
type="text/css" />
<!--[if IE 6]>
<script type="text/javascript" src="http://lib.h-ui.net/DD_belatedPNG_0.0.8a-min.js" ></script>
<script>DD_belatedPNG.fix('*');</script>
<![endif]-->

<style type="text/css">
</style>
<title>文章管理</title>
</head>
<body>
	<c:if test="${empty cate_id}">
	<nav class="breadcrumb">
		<i class="Hui-iconfont">&#xe67f;</i> 首页 <span class="c-gray en">&gt;</span>
		文章 <span class="c-gray en">&gt;</span> 文章管理 <a
		class="btn btn-success btn-refresh radius r mt-5 mr-20"
		onclick="javascript:location.replace(location.href);"
		href="javascript:location.replace(location.href);" title="刷新">刷新</a>

		<a class="btn btn-primary radius r mt-5 mr-20"
		onclick="Hui_admin_tab(this)"
		_href="<%=path%>/backstage/articleaddpre" data-title="添加文章"
		href="javascript:void(0);">添加文章</a> <a
		class="btn btn-primary radius r mt-5 mr-20"
		onclick="Hui_admin_tab(this)"
		_href="<%=path%>/backstage/articleaddpre2" data-title="添加图说"
		href="javascript:void(0);">添加图说</a> <a
		class="btn btn-primary radius r mt-5 mr-20"
		onclick="Hui_admin_tab(this)"
		_href="<%=path%>/backstage/articleaddpre3" data-title="添加视频"
		href="javascript:void(0);">添加视频</a>
	</nav>
</c:if>
<div class="pd-20">
	<c:if test="${empty cate_id}">
	<div class="cl pd-5 bg-1 bk-gray">
		<span class="l"><a href="javascript:;"
			onclick="article_delete_batch()" class="btn btn-danger radius"><i
			class="Hui-iconfont">&#xe6e2;</i> 批量删除</a></span>
			<form action="<%=path%>/backstage/article-list" method="get"
				class="form form-horizontal" id="search-form">
				<div class="cl">
					<label class="form-label col-2">标题：</label>
					<div class="formControls col-3">
						<input type="text" name="title" value="" id="title"
						placeholder="标题" class="input-text col-3">
					</div>
					<div class="formControls col-3">
						<button name="" id="" class="btn btn-success radius ml-20 mr-10"
						type="submit">查询</button>
						<button name="" onclick="theReset();" id=""
						class="btn radius btn-success">重置</button>
					</div>
				</div>
			</form>
		</div>
	</c:if>

	<div class="mt-20">
		<table
		class="table table-border table-bordered table-hover table-bg table-sort">
		<thead>
			<tr class="text-c">
				<th width="35"><input type="checkbox" name="" value=""></th>
				<th width="20">ID</th>
				<th>标题</th>
				<th width="40">点击</th>
				<th width="150">添加时间</th>
				<th>分类</th>
				<th width="150">操作</th>
			</tr>
		</thead>
		<tbody>
			<c:forEach items="${u_articles}" var="u_article" varStatus="l">

			<tr class="text-c">
				<td><input type="checkbox" value="${u_article.id}" id="id"
					name="id"></td>
					<td>${l.index+1}</td>

					<td>${u_article.title}</td>

					<td>${u_article.read_count}</td>
<%-- 
							<td><c:forEach items="${users}" var="user">
									<c:if test="${user.user_id==u_article.creater_id}">
										${user.user_name}
									</c:if>
								</c:forEach></td> --%>
								<td>${u_article.add_time}</td>
								<td>${u_article.cates_Html}</td>
							<%-- <td><c:choose>
									<c:when test="${1==u_article.is_visiable}">
										<span class="label label-success radius"> <a
											style="text-decoration: none; color: white"
											onClick="u_article_show(this,'${u_article.id}')"
											href="javascript:void(0);" title="不展示">不展示</a>
										</span>
									</c:when>
									<c:otherwise>
										<span class="label label-warning radius"> <a
											style="text-decoration: none; color: white"
											onClick="u_article_show(this,'${u_article.id}')"
											href="javascript:void(0);" title="展示">展示</a>
										</span>
									</c:otherwise>
								</c:choose></td> --%>
								<td class="td-manage"><a class="btn btn-warning"
									onClick="u_article_edit(this,'${u_article.id}')"
									href="javascript:void(0);" title="编辑">编辑</a> &nbsp;&nbsp;<a class="btn btn-warning"
									onClick="u_article_delete(this,'${u_article.id}')"
									href="javascript:void(0);" title="删除">删除</a></td>
								</tr>
							</c:forEach>
						</tbody>
					</table>
				</div>
			</div>
			<script type="text/javascript"
			src="<%=basePath%>backstage/lib/jquery/1.9.1/jquery.min.js"></script>
			<script type="text/javascript"
			src="<%=basePath%>backstage/lib/layer/1.9.3/layer.js"></script>
			<script type="text/javascript"
			src="<%=basePath%>backstage/lib/laypage/1.2/laypage.js"></script>
			<script type="text/javascript"
			src="<%=basePath%>backstage/lib/My97DatePicker/WdatePicker.js"></script>
			<script type="text/javascript"
			src="<%=basePath%>backstage/lib/datatables/1.10.0/jquery.dataTables.min.js"></script>
			<script type="text/javascript" src="<%=basePath%>backstage/js/H-ui.js"></script>
			<script type="text/javascript"
			src="<%=basePath%>backstage/js/H-ui.admin.js"></script>
			<script type="text/javascript">
				$(function() {
					$('.table-sort').dataTable({
				"aaSorting" : [ [ 6, "desc" ] ],//默认第几个排序
				"bStateSave" : true,//状态保存
				"aoColumnDefs" : [
				//{"bVisible": false, "aTargets": [ 3 ]} //控制列的隐藏显示
				{
					"orderable" : false,
					"aTargets" : [ 1, 2 ]
				} // 制定列不参与排序
				]
			});
					$('.table-sort tbody').on('click', 'tr', function() {
						if ($(this).hasClass('selected')) {
							$(this).removeClass('selected');
						} else {
							table.$('tr.selected').removeClass('selected');
							$(this).addClass('selected');
						}
					});
				});
				
				/*重置*/
				function theReset(){
					$("#search-form input[type='text']").val('');
					$("#search-form select").val(-1);
				}

				/*添加*/
				function u_article_add(title, url, w, h) {
					layer_show(title, url, w, h);
				}

				/*编辑*/
				function u_article_edit(obj,id,w,h){
					var edit_page = "<%=basePath%>backstage/article-show?article_id="+id;
					var index = layer.open({
						type: 2,
						title: "编辑",
						content: edit_page
					});
					layer.full(index);
				}

				/*批量删除*/
				function article_delete_batch(){
					var article_ids = $("input[name='id']:checked");
					var ids = "";
					for (var i = 0; i < article_ids.length; i++){
						ids += "," + article_ids[i].value; 
					}
			//
			layer.confirm('确认删除吗？', {
				btn: ['确认','取消'], 
				shade: false
			},
			function(){
				$.ajax({
					type : "POST",
					url : "<%=basePath%>backstage/article-delete-batch",
					data : "article_ids=" + ids,
					error : function() {
						layer.msg('操作失败', {icon:5,time:1000});
					},
					success : function(msg) {
						layer.msg('操作成功 ', {icon:6,time:1000});
						$("body").find(".btn-refresh").click();
					}
				});
			},
			function(){
				layer.msg('未删除', {icon:5,time:1000});
			});	
		}
		
		function u_article_show(obj,id){
			layer.confirm('确认展示？', {
				btn: ['确认','取消'], 
				shade: false
			},
			function(){
				$.ajax({
					type : "POST",
					url : "<%=basePath%>backstage/articleshow",
					data : "article_id=" + id,
					error : function() {
						layer.msg('操作失败', {
							icon : 5,
							time : 1000
						});
					},
					success : function(msg) {

						layer.msg('操作成功', {
							icon : 6,
							time : 1000
						});
						$(obj).parents("body").find(".btn-refresh").click();
					}
				});
			}, function() {
				layer.msg('未删除', {
					icon : 5,
					time : 1000
				});
			});
		}

		/*删除*/
		function u_article_delete(obj,id){
			layer.confirm('确认删除?', {
				btn: ['确认','取消'], 
				shade: false
			},
			function(){
				$.ajax({
					type : "POST",
					url : "<%=basePath%>backstage/articledelete",
					data : "id=" + id,
					error : function() {
						layer.msg('操作失败', {
							icon : 5,
							time : 1000
						});
					},
					success : function(msg) {
						layer.msg('已删除 ' + msg.information, {
							icon : 6,
							time : 1000
						});
						$(obj).parents("body").find(".btn-refresh").click();
					}
				});
			}, function() {
				layer.msg('未删除', {
					icon : 5,
					time : 1000
				});
			});
		}
	</script>
</body>
</html>



